import type { FieldConfig } from '@/components/TableFilter.vue'
import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '項目名稱',
    dataIndex: 'name',
  },
  {
    title: 'CODE',
    dataIndex: 'code',
  },
  {
    title: '描述',
    dataIndex: 'description',
  },
  {
    title: '最後修改人',
    dataIndex: 'updatedBy',
  },
  {
    title: '最後修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]
// 過濾項配置
export const filterFields: FieldConfig[] = [
  {
    name: 'name',
    label: '項目名稱',
    type: 'input',
    placeholder: '請輸入項目名稱',
  },
  {
    name: 'code',
    label: 'CODE',
    type: 'input',
    placeholder: '請輸入CODE',
  },
]

// 表單字段配置
const FormField: Record<string, FormFieldConfig> = {
  name: {
    label: '項目名稱',
    type: 'input',
    placeholder: '請輸入項目名稱',
    rules: [{ required: true, message: '請輸入項目名稱' }],
  },
  code: {
    label: 'CODE',
    type: 'input',
    placeholder: '請輸入CODE',
    rules: [{ required: true, message: '請輸入CODE' }],
  },

  description: {
    label: '描述',
    type: 'input',
    placeholder: '請輸入描述',
  },
}

// 創建表單字段
export const getCreteFieldConfig = (createFields?: string[]) => {
  return getFormFields(FormField, createFields)
}

export const getEditFieldConfig = (editFields?: string[]) => {
  return getFormFields(FormField, editFields)
}
